-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversion performance improvement #594
base: main
Are you sure you want to change the base?
Conversation
Boro Sofranac seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Does anyone have any idea what could cause python3.8 to fail the QAOA test, while other python versions work? Maybe some of you had similar experiences before? Here's what I know:
The failure happens because the qaoa finishes with an suboptimal solution [1,1] (objective val 7) while cplex finds the optimum [0,2] (objective val 6) |
It does seem rather a puzzle as to why CI is failing here. Locally on a linux system I created a new env with Python 3..8.18, as its using here, and locally modifying the QuadraticExpression code the same the test works - whether I run it the same as done in CI, i.e using stestr, via One could try and put some temporary prints to come out in the log in an attempt to figure things out - but I can imagine this not being very productive. Locally I printed the coeffs built during the test that fails to those built the former way and looking over things they seemed the same - but the test passed for me anyways. I could see 2 ways to proceed as-is with further trying to figure why it fails here - simply accept that for 3.8 it works, based on the fact that tests run outside locally work, and augment the test that is failing to skip it under Python 3.8, leaving whatever mystery is causing the failure be and that logic untested under 3.8 by CI. The other would be to change the code so it conditionally goes down the new, more performant, code path only for Python 3.9 or above, and for 3.8 therefore still does it as its currently done. That would still have it run and pass (as it does now hopefully!) in CI but a user a would not get the speed up under 3.8. Qiskit has been supporting Python versions until their EOL - for 3.8 thats 14th Oct 2024, so 8 months away where shortly thereafter I would imagine dropping 3.8 support anyway not long after Qiskit does so. I guess I like to see stuff tested so I would more lean to the 2nd option personally rather than assume it carries on working, based on having seen that at this moment it runs/passes locally. Either way still leaves the mystery unsolved but without being able to reproduce it locally it seems it may have to remain a mystery. And of course put some comment at the location of whatevers changed to workaround this about the CI failure and why things look like they do. |
Pull Request Test Coverage Report for Build 8298754055Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Summary
The purpose of this merge request is to find easy wins in improving the performance of converters.
Details and comments
I ran some tests to see where the bottleneck in conversion lies. I used the
enlight11.mps
file, and tried to convert it to QUBO. On my machine, this is the breakdown of timings in seconds per the conversion step for this instance:By far the most time is spent in the
LinearEqualityToPenalty
converter. Out of ~10.3 seconds spent in this converter, ~9.3 seconds are spent in the_coeffs_to_dok_matrix
function while processing the quadratic coefficients of the resulting QUBO.This function first builds the QUBO matrix out of a dictionary of coefficients in full form (both upper and lower triangular elements are added), and then transforms it into an upper diagonal form via matrix operations. As these operations can be expensive, the proposed change simply directly builds the matrix in upper triangular form, avoiding several intermediate steps
In the following table, the conversion time is compared before and after the improvements for a few instances:
✅ I have added the tests to cover my changes.
✅ I have updated the documentation accordingly. [nothing to be updated]
✅ I have read the CONTRIBUTING document.